<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCartTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cart', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('goods_id')->comment('商品id');
            $table->integer('attr_id')->comment('商品属性id');
            $table->integer('user_id')->comment('用户id');
            $table->integer('cart_num')->default(1)->comment('购买数量');
            $table->string('cart_img', 150)->default('')->comment('商品图片');
            $table->decimal('cart_price', 10,2)->default(0.00)->comment('商品单价');
            $table->index('user_id');
            $table->index('goods_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('cart');
    }
}
